export default{
    initHtml(ScreenData={},param,callback){
        var html = '<ul id="'+param.cpname+'_menu" class="nav nav-list" style="height:100%;width:100%;background-color:#f2f2f2;border-style: solid;border-color: #cccccc;border-width: 0 1px 1px 1px;"></ul>'
        
        $(param.menuBoxId).append(html)

        callback();
    },

    initMenuContent(custom,data=[],param,callback){
        let _this = this;
        
        $.each(data,function(key,value){
            var html = `<li class="hover `+value['class']+`" id="`+value.menuname+`" >
                            <a href="javascript:void(0)">
                                <i class="menu-icon `+value.icon+`" style="vertical-align: middle;"></i>
                                <span class="menu-text"  style="vertical-align: middle;">`+value.text+`</span>
                            </a>
                            <b class="arrow"></b>
                        </li>`
            $("#"+param.cpname+"_menu").append(html)

            if(value['onclick']!=""){
                $("#"+param.cpname+"_menu").find("#"+value.menuname).unbind("click").click(function(){
                    var html = _this.reconvert(value['onclick'])
                    eval(html);
                })
            }
            
        })

    },

    //unicode转utf-8
    reconvert:function(str){ 
            str = str.replace(/(\\u)(\w{1,4})/gi,function($0){ 
                return (String.fromCharCode(parseInt((escape($0).replace(/(%5Cu)(\w{1,4})/g,"$2")),16))); 
            }); 
            str = str.replace(/(&#x)(\w{1,4});/gi,function($0){ 
                return String.fromCharCode(parseInt(escape($0).replace(/(%26%23x)(\w{1,4})(%3B)/g,"$2"),16)); 
            }); 
            str = str.replace(/(&#)(\d{1,6});/gi,function($0){ 
                return String.fromCharCode(parseInt(escape($0).replace(/(%26%23)(\d{1,6})(%3B)/g,"$2"))); 
            }); 
             
            return str; 
    }
}